import type { SelectProps } from 'antd';

const booleanOptions: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'true',
    label: '是'
  },
  {
    value: 'false',
    label: '否'
  }
];

const userTypes: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'Normal',
    label: '未授权用户'
  },
  {
    value: 'Authorized',
    label: '授权用户'
  }
];

const verificationCodeUsages: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'SignUp',
    label: '注册用户'
  },
  {
    value: 'ResetPassword',
    label: '重置密码'
  }
];

const appTypes: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'Netease',
    label: '网易邮箱'
  },
  {
    value: 'Wechat',
    label: '企业微信'
  },
  {
    value: 'DingTalk',
    label: '钉钉'
  },
  {
    value: 'Feishu',
    label: '飞书'
  }
];

const taskFrequencies: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'Once',
    label: '一次'
  },
  {
    value: 'Daily',
    label: '每天'
  },
  {
    value: 'Weekly',
    label: '每周'
  },
  {
    value: 'Monthly',
    label: '每月'
  }
];

const executeStatuses: SelectProps['options'] = [
  {
    value: '',
    label: ''
  },
  {
    value: 'Created',
    label: '已创建'
  },
  {
    value: 'Started',
    label: '已开始'
  },
  {
    value: 'Ended',
    label: '已结束'
  },
  {
    value: 'Error',
    label: '产生错误'
  }
];

const getOptionLabel = (items: SelectProps['options'], value: any) => {
  let item: any = null;
  if (items?.length) {
    for (let i = 0; i < items?.length; i++) {
      if (items[i].value === value) {
        item = items[i];
        break;
      }
    }
  }
  return item ? item.label : value;
};

export {
  booleanOptions,
  userTypes,
  verificationCodeUsages,
  appTypes,
  taskFrequencies,
  executeStatuses,
  getOptionLabel
};
